/* CodeBuilder代码生成器 创建时间：2011-12-03 18:58:20 */
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using Maticsoft.DBUtility;
namespace DAL
{
	/// <summary>
	/// 数据访问类:V_AdminLog 
	/// </summary>
	public partial class V_AdminLog :  DALHandlerBase<Model.V_AdminLog>
	{
		public V_AdminLog()
		{
            base.TableName = "V_AdminLog";
        }
		#region  Method

        		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		    return DbHelperSQL.GetMaxID("$ID", "V_AdminLog"); 
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public Model.PageData<Model.V_AdminLog> GetList(int PageSize,int PageIndex,string strWhere,string filedOrder)
		{
            SqlParameter[] parameters = {
                    new SqlParameter("@sqlstr", SqlDbType.NVarChar, 4000),
                    new SqlParameter("@pageindex", SqlDbType.Int),
                    new SqlParameter("@pagesize", SqlDbType.Int),
                    };
            StringBuilder strSql=new StringBuilder();
            strSql.AppendFormat("SELECT * FROM {0}",base.TableName);
            if(!string.IsNullOrEmpty(strWhere))
			{
				strSql.AppendFormat(" WHERE {0}",strWhere);
			}
            if(!string.IsNullOrEmpty(filedOrder))
            {
			    strSql.AppendFormat(" ORDER by {0}",filedOrder);
            }
            parameters[0].Value = strSql.ToString();
            parameters[1].Value = PageIndex;
            parameters[2].Value = PageSize;

            DataSet ds = DbHelperSQL.RunProcedure("SP_pagination", parameters, "ds");
            Model.PageData<Model.V_AdminLog> data = new Model.PageData<Model.V_AdminLog>();
            data.PageIndex = PageIndex;
            data.PageSize = PageSize;
            data.Count =  Convert.ToInt32(ds.Tables[1].Rows[0]["Count"]);
            data.DataSoure = base.DataTableToList(ds.Tables[2]);

            return data;
		}

		#endregion  Method
	}
}

